---
title: What are Knowledge Filters?
sidebarTitle: Overview
description: Use knowledge filters to restrict and refine searches
keywords: [knowledge filters]
---

Knowledge filters allow you to restrict and refine searches within your knowledge base using metadata such as user IDs, document types, years, and more. This feature is especially useful when you have a large collection of documents and want to retrieve information relevant to specific users or contexts.

## Why Use Knowledge Filters?

- **Personalization:** Retrieve information for a specific user or group.
- **Security:** Restrict access to sensitive documents.
- **Efficiency:** Reduce noise by narrowing down search results.

## How Do Knowledge Filters Work?

When you load documents into your knowledge base, you can attach metadata (like user ID, document type, year, etc.). Later, when querying, you can specify filters to only search documents matching certain criteria.

**Example Metadata:**
```python
{
    "user_id": "jordan_mitchell",
    "document_type": "cv",
    "year": 2025,
}
```

## Ways to Apply Filters

You can apply knowledge filters in two main ways:
1. **Manual Filters:** Explicitly pass filters when querying.
2. **Agentic Filters:** Let the Agent automatically extract filters from your query.

> **Tip:** You can combine multiple filters for more precise results!

## Filters in Traditional RAG vs. Agentic RAG

When configuring your Agent it is important to choose the right approach for your use case. There are two broad approaches to RAG with Agno agents: traditional RAG and agentic RAG. With a traditional RAG approach you set `add_knowledge_to_context=True` to ensure that references are included in the system message sent to the LLM. For Agentic RAG, you set `search_knowledge=True` to leverage the agent's ability search the knowledge base directly.

Example:
```python
agent = Agent(
    name="KnowledgeFilterAgent",
    search_knowledge=False,  # Do not use agentic search
    add_knowledge_to_context=True,     # Add knowledge base references to the system prompt
    knowledge_filters={"user_id": "jordan_mitchell"}, # Pass filters like this
)
```

<Check> 
Remember to use only one of these configurations at a time, setting the other to false. By default, `search_knowledge=True` is preferred as it offers a more dynamic and interactive experience.
Checkout an example [here](/examples/concepts/knowledge/filters/filtering) of how to set up knowledge filters in a Traditional RAG system
</Check>

## Best Practices

- Make your prompts descriptive (e.g., include user names, document types, years).
- Use agentic filtering for interactive applications or chatbots.

## Manual vs. Agentic Filtering

| Manual Filtering | Agentic Filtering |
|------------------|------------------|
| Explicit filters in code | Filters inferred from query text |
| Full control | More natural, less code |
| Good for automation | Good for user-facing apps |

<Note>
🚦 **Currently, knowledge filtering is supported on the following vector databases:**

- **Qdrant**
- **LanceDB**
- **PgVector**
- **MongoDB**
- **Pinecone**
- **Weaviate**
- **ChromaDB**
- **Milvus**
</Note>

## Developer Resources
See the detailed cookbooks [here](https://github.com/agno-agi/agno/blob/main/cookbook/knowledge/filters/README.md)